package com.gayworld.service.model;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.gayworld.controller.vo.ActionVO;
import com.gayworld.model.dao.ActionDAO;
import com.gayworld.model.dao.PlacesDAO;
import com.gayworld.model.entity.Action;
import com.gayworld.model.entity.Places;
import com.gayworld.model.noentity.ActionType;

@Service
@Transactional
public class ActionServiceImpl implements ActionService{
	
 
	@Autowired
	private ActionDAO actionDAO;
	

	@Autowired
	private PlacesDAO placesDAO;
	
	@Override
	public void create(ActionVO actionVO){
		Action action = new Action();
		Places p =  placesDAO.findById(Places.class, actionVO.getPlaceId());
		
		
		action.setPlace(p);
		action.setPetitionReason(actionVO.getPetitionReason());
		action.setRegisterDate(new Date());
		action.setUserIp(actionVO.getUserIp());
		action.setPetitionType(ActionType.valueOf(actionVO.getPetitionType()));
	//	action.setWarningFlag(warningFlag);
		actionDAO.save(action);		
	}
	
}
